<?php

namespace longhu\generate\factory;

use longhu\exceptions\FailedException;
use longhu\myGenerator\build\BaseClass;
use longhu\myGenerator\Generator;

class Dao extends Factory
{
    public function done(array $params):string
    {
        $content = $this->getContent($params);
    }

    public function getContent(array $params)
    {
        $model = $params['model'];
        $dao = $params['dao'];

        [$modelName, $namespace] = $this->parseFilename($params['model']);
        [$daoName, $namespaceName] = $this->parseFilename($dao);
        if (!$daoName) {
            throw new FailedException('daoName name not set');
        }

        return Generator::namespace($namespaceName)->class($daoName,function (BaseClass $class, Generator $generator){
            $class->extend('Dao');
            //设置方法
            $generator->method('setModel');
        })->uses([
                $modelName
        ])->print();
    }
}